Entry

interface Entry<T, E : Entry<T, E>> : EntryHandler<T> , EntryWidget<T> , EntryFlag, Consumer<T> , Supplier<T>

A base Entry for configs.

Performs 10 basic functions

  • serialize contents

  • deserialize input

  • validate updates

  • correct errors

  • provide widgets

  • apply inputs

  • supply outputs

  • create instances

  • manages flags

  • accepts listeners

Author

fzzyhmstrs

Since

0.2.0, add EntryFlag 0.5.6, add listenToEntry 0.6.0

Parameters

T

the non-null type of the Entry stored value

Inheritors

Functions

Link copied to clipboard
abstract fun accept(p0: T)
Link copied to clipboard
open fun andThen(p0: Consumer<in T>): Consumer<T>
Link copied to clipboard
open fun copyValue(input: T): T

Copies the provided input as deeply as possible.

Link copied to clipboard

Corrects an attempted input, as possible. When correction isn't possible or deterministic, simply validate the entry the same way you would for EntryValidator

Link copied to clipboard
open fun deserializedChanged(old: Any?, new: Any?): Boolean

Specialized equals method for determining if a newly deserialized value is effectively equal to its old counterpart.

Link copied to clipboard
abstract fun deserializeEntry(toml: TomlElement, errorBuilder: MutableList<String>, fieldName: String, flags: Byte): ValidationResult<T>

Deserializes the provided TomlElement. This deserialization should store the result within this deserializer (deserialize "in-place") as well as returning the result. The return has to have a fallback value.

Link copied to clipboard
open fun flags(): Byte
Link copied to clipboard
abstract fun get(): T
Link copied to clipboard
open fun hasFlag(flag: EntryFlag.Flag): Boolean
Link copied to clipboard
abstract fun instanceEntry(): E

Creates as deep a copy as possible of this Entry

Link copied to clipboard
abstract fun isValidEntry(input: Any?): Boolean

Tests an arbitrary input to determine if it is a valid input to this Entry. Inputs are not (necessarily) Entry, the term is used here in the general sense

Link copied to clipboard
abstract fun listenToEntry(listener: Consumer<Entry<T, *>>)

Applies a listener to this entry. The consumer(s) passed be invoked whenever the value of this Entry is updated

Link copied to clipboard
abstract fun serializeEntry(input: T?, errorBuilder: MutableList<String>, flags: Byte): TomlElement

Serializes either the provided input or stored value to a TomlElement

Link copied to clipboard
abstract fun trySet(input: Any?)

Attempts to set an arbitrary input into this Entry. Should fail soft if the input is incompatible

Link copied to clipboard

Validates an input per the provided validation type.

Link copied to clipboard
open fun widgetAndTooltipEntry(choicePredicate: ChoiceValidator<T> = ChoiceValidator.any()): ClickableWidget

Builds a new ClickableWidget and applies a tooltip to it. This shouldn't need to be overridden in most cases

Link copied to clipboard
abstract fun widgetEntry(choicePredicate: ChoiceValidator<T> = ChoiceValidator.any()): ClickableWidget

Builds a new ClickableWidget for use in a config GUI. If the widget is presenting options that could be filtered by the optional ChoiceValidator, those possible selections should be filtered in some way by the validator before presenting to the user.